﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DomainDriver.CommonUtilities.Reflectors;
using DomainDriver.DomainModeling.Attributes;
using DomainDriver.DomainModeling.DomainModels;
using DomainDriver.DomainModeling.DomainObjects;

namespace DomainDriver.DomainModeling.Example.DomainObjects
{
    public partial class SingletonDomainObject : KeyedDomainObjectBase<Guid, SingletonDomainObject>
    {
        #region Static Members

        public static SingletonDomainObject CreateSingleton(IDomainModel domainModel)
        {
            return new SingletonDomainObject();
        }

        #endregion

        private Nullable<EnumerationValue> m_SelectedEnumerationDomainObjectId;

        public SingletonDomainObject()
            : this(null)
        { }

        public SingletonDomainObject(Nullable<EnumerationValue> selectedEnumerationDomainObjectId)
        {
            m_Key = Guid.NewGuid();
            m_SelectedEnumerationDomainObjectId = selectedEnumerationDomainObjectId;
        }

        // LATER: Add "[NotNull]" and make sure it still works
        public Nullable<EnumerationValue> SelectedEnumerationDomainObjectId
        {
            get { return m_SelectedEnumerationDomainObjectId; }
            set { m_SelectedEnumerationDomainObjectId = value; }
        }

        #region DomainObject Methods

        public override SingletonDomainObject Copy()
        {
            SingletonDomainObject newObject = new SingletonDomainObject();
            CopyTo(newObject);
            return newObject;
        }

        public override void CopyTo(SingletonDomainObject receivingObject)
        {
            receivingObject.m_Key = m_Key;
            receivingObject.m_SelectedEnumerationDomainObjectId = m_SelectedEnumerationDomainObjectId;
        }

        public override bool Equals(SingletonDomainObject otherObject)
        {
            if (!m_Key.Equals(otherObject.m_Key))
            { return false; }
            if (!m_SelectedEnumerationDomainObjectId.Equals(otherObject.m_SelectedEnumerationDomainObjectId))
            { return false; }
            return true;
        }

        #endregion
    }
}